/*	TGDefaultsModel.h
 *	Part of ThinkGeek LED Clock
 *	http://cs.beloit.edu/~morgant/thinkgeek/
 *
 * Copyright (c)2003-2005 Tim Morgan. All rights reserved.
 * Please visit http://cs.beloit.edu/~morgant/other/license.html
 * for more information about your rights and responsibilities
 * regarding this source code.
 */

#import <Cocoa/Cocoa.h>

#import "../TGStringConstants.h"

/**
 * Singleton class that stores global and persistent user settings.
 * This model should be populated with user settings as loaded from
 * a file using <code>ScreenSaverDefaults</code>. The model will
 * then be responsible for storing these defaults and making them
 * accessible to the rest of the program.
 *
 * @author Tim Morgan
 */

@interface TGDefaultsModel : NSObject {
	NSMutableDictionary	*defaults;
	NSMutableDictionary	*standardDefaults;
	BOOL				errorInDefaults;
}

#pragma mark <<initialization/singleton/deallocation>>

- (void) awakeFromNib;

/**
 * Returns the singleton instance of this class.
 *
 * @return The singleton instance
 */

+ (TGDefaultsModel *) defaultsModel;
- (void) dealloc;

#pragma mark <<properties>>
- (NSArray *) keys;

#pragma mark <<plug-ins>>
- (void) addStandardDefaults:(NSDictionary *)moreDefaults;

#pragma mark <<program constants>>
- (NSString *) version;

#pragma mark <<user settings>>
- (id) defaultForKey:(NSString *)key;
- (id) standardDefaultForKey:(NSString *)key;
- (void) setDefault:(id)newDefault forKey:(NSString *)key;

- (NSColor *) backgroundColor;
- (void) setBackgroundColor:(NSColor *)newColor;

- (NSString *) backgroundImageFilePath;
- (void) setBackgroundImageFilePath:(NSString *)newPath;

- (NSString *) backgroundStyle;
- (void) setBackgroundStyle:(NSString *)newStyle;

- (BOOL) checkUpdatesAutomatically;
- (void) setCheckUpdatesAutomatically:(BOOL)willCheck;

- (float) clockSize;
- (void) setClockSize:(float)newSize;

- (NSString *) clockTheme;
- (void) setClockTheme:(NSString *)newTheme;

- (BOOL) isTimeFormat24Hour;
- (void) setTimeFormat24Hour:(BOOL)is24Hour;

#pragma mark <<validation>>
- (BOOL) validateBackgroundStyle:(id *)objectToValidatePtr error:(NSError **)outError;
- (BOOL) validateBackgroundImageFilePath:(id *)objectToValidatePtr error:(NSError **)outError;
- (BOOL) validateClockSize:(id *)objectToValidatePtr error:(NSError **)outError;

#pragma mark <<error handling>>

/**
 * Returns true if an error was found in the defaults the last time they were loaded.
 * An object displaying the defaults to the user can check this flag to determine if
 * they need to notify the user that the defaults have been changed (since any invalid
 * parameters are reset to their standard values.
 *
 * The flag is reset after this method is called.
 *
 * @return True if a default was invalid, false if all defaults were good
 */

- (BOOL) errorInDefaults;
//- (void) setValue:(id)value forUndefinedKey:(NSString *)key;
//- (id) valueForUndefinedKey:(NSString *)key;

@end
